<%@page import="Entity.User"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>用户管理</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link rel="shortcut icon" type="image/x-icon" href="logo.jpg" />
	<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
	<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
	<script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
	<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
	<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css">
	<style>
		body {
		  font-family: Arial;
		  background-image: linear-gradient(to top, #e6e9f0 0%, #eef1f5 100%);
		}
		
		* {
		  box-sizing: border-box;
		}
		
		form.example input[type=text] {
		  padding: 10px;
		  font-size: 17px;
		  border: 1px solid grey;
		  float: left;
		  width: 80%;
		  background: #f1f1f1;
		}
		
		form.example button {
		  float: left;
		  width: 20%;
		  padding: 10px;
		  background: #2196F3;
		  color: white;
		  font-size: 17px;
		  border: 1px solid grey;
		  border-left: none;
		  cursor: pointer;
		}
		
		form.example button:hover {
		  background: #0b7dda;
		}
		
		form.example::after {
		  content: "";
		  clear: both;
		  display: table;
		}
	</style>
  </head>
  
  <body>
  	<%
  	User user1 =(User) session.getAttribute("user");
  	 if(user1==null){
  	 	 request.getRequestDispatcher("login.jsp").forward(request,response);
  	 	 }
  		List<User> users =(List<User>)request.getAttribute("users");
  		int cpage;
  		if(request.getAttribute("cpage")!=null){
  			cpage=((Integer)request.getAttribute("cpage")).intValue();
  		}
  		else{
  			cpage=0;
  		}
  		int totalPage;
  		if(request.getAttribute("sum")!=null){
  			totalPage=((Integer)request.getAttribute("sum")).intValue();
  		}
  		else{
  			totalPage=0;
  		}
  		
  	 %>
  	<!-- 顶部-->
  	<div style="border: 1px;display: block;">
   			<image  src="image/title.png" style="width: 600px;">
   			<a href="personInfor.jsp" class="btn dropdown-toggle"  style="float: right;margin:auto 40px;">
   			<i class="fa fa-user-circle fa-2x"></i>
   			个人信息
	   		 </a>
   	</div>
	<!-- 导航-->
	<div style="float: left;width: 10%;height:90%; bottom:0;display: block;border-radius: 10px;
   		background-image: linear-gradient(to top,#accbee 0%, #e7f0fd 100%);">
   		<ul class="nav nav-pills nav-stacked">
			  <li ><a href="RoomServlet"><img src="image/m_1.png" width="25px" style="margin-right: 5px;">机房信息</a></li>
			  <li class="active"><a href="SearchServlet?cpage=1">用户信息</a></li>
				  <li>
					<a type="button" class="btn " data-toggle="collapse" 
					    data-target="#demo" >
					     实验安排
					</a>    
					<div id="demo" class="collapse"  style="text-align: center;
						background-image: linear-gradient(to top, #accbee 0%, #e7f0fd 100%);">
					  <a class="btn " href="class_total.jsp" style="color: white;">课程日历</a>
					 <a class="btn " href="searchCourseServlet?page=1" style="color: white;">查看课程</a>
					</div>
				  <li><a href="EventServlet?page=1">考试/竞赛</a></li>
				  <li><a href="sendmessage.jsp">发件箱</a></li>
			</ul>
 	</div>
    		<!-- 主体-->
    		
    		<div style="float: left;margin:0 10px 5px 40px;">
    		
		   	 <form class="example" method="post" action="SearchServlet?cpage=1" style="margin:10px auto;max-width:800px">
		   
			  <input type="text" placeholder="输入关键字.." name="search" >
			  <button type="submit" style="height: 46px;"><i class="fa fa-search"></i></button>
			
			
			    <table class="table table-striped" style="max-height: 300px;width: 900px; margin:0 auto;">  
			
			            <thead>
			                <tr>
			                    <th>工号</th>
			                    <th>姓名</th>
			                    <th>发邮件</th>
			                   
			                </tr>  
			            </thead>
			            <tbody>
			            
			           <% 
			           if(users!=null){
	    			for( User user:users){
		    		%><tr>
		    			<td><%=user.getUid() %></td>
		    			<td><%=user.getUname() %></td>
		    			<td><a href="m_link.jsp"><span class="glyphicon glyphicon-envelope"></span></a></td>
		    			</tr>
		    		<%
		    		}
		    		
		    		 %>
			            </tbody>    
				</table>  
				</form>
				<div style="text-align: center;margin: 20px auto;">
				<%
					if(cpage==1){
						if(cpage!=totalPage){
					
					%>
							共<%=cpage %>/<%=totalPage %>页
							<a href="SearchServlet?cpage=<%=cpage+1 %>">下一页</a>
							<a href="SearchServlet?cpage=<%=totalPage %>">尾页</a>
					<%
						}else if(cpage==totalPage){
						%>
							共1/1页
						<%
						}
					}else if(cpage==totalPage){
						%>
							共<%=cpage %>/<%=totalPage %>页
							<a href="SearchServlet?cpage=1">首页</a>
							<a href="SearchServlet?cpage=<%=cpage-1 %>">上一页</a>
						<%
					}else{
						%>
							<a href="SearchServlet?cpage=1">首页</a>
							<a href="SearchServlet?cpage=<%=cpage-1 %>">上一页</a>
							共<%=cpage %>/<%=totalPage %>页
							<a href="SearchServlet?cpage=<%=cpage+1 %>">下一页</a>
							<a href="SearchServlet?cpage=<%=totalPage %>">尾页</a>
						<%
					}
					}
				 %>
				
				</div>
			</div>
			<div style="float: left;margin-left:40px;">
	    			<form action="addUser" method="post" enctype="multipart/form-data" name="file" id="file">
	    			<input type="file" name="user_file" value="导入名单"><br>
	    			<button type="submit" class="btn-primary">提交</button>
	    			</form>
	    	</div>
	    	
  </body>
</html>
